home *** CD-ROM | disk | FTP | other *** search
/ Amiga News 95 / Amiga News 95.iso / dpat / dpat31 / iobject / sources.lha / sources / IObject_priv.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-23  |  9.0 KB  |  324 lines

  1. // Include pour les objets
  2. // (C) 1992 Christophe PASSUELLO
  3. // Tue Mar 23 17:32:54 1993
  4.  
  5.  
  6. #ifndef EXEC_TYPES_H
  7. #include "exec/types.h"
  8. #endif
  9.  
  10. #ifndef 
  11. #define  INTUITION_PREFERENCES_H TRUE
  12. #endif
  13. #include <intuition/intuition.h>
  14.  
  15.  
  16. // GadgetID pour les objets
  17. #define OBJECTID    0x0ACE
  18.  
  19. #define COPY_BOX(dest,src) (*((struct Box *)dest))=(*((struct Box *)src))
  20.  
  21.  
  22. // definition d'une boite
  23. struct Box
  24. {
  25.     UWORD x, y;
  26.     UWORD w, h;
  27. };
  28.  
  29. // Type de bordure pour Draw3DBox
  30. #define BOX_1IN        0
  31. #define BOX_1OUT    1
  32. #define BOX_2IN        2
  33. #define BOX_2OUT    3
  34.  
  35.  
  36. // Table des methodes virtuelles
  37. struct ObjectTMV
  38. {
  39.     UWORD Class;
  40.     UWORD Size;
  41.     VOID  (*Free) (struct Object *);
  42.     BOOL  (*SendMsg) (struct Object *, struct IntuiMessage *);
  43.     VOID  (*Add) (struct Object *, struct Window *, struct Requester *);
  44.     VOID  (*Remove) (struct Object *);
  45.     VOID  (*Display) (struct Object *);
  46.     VOID  (*Erase) (struct Object *);
  47.     VOID  (*Modify) (struct Object *, ...);
  48.     VOID  (*Value) (struct Object *);
  49.     VOID  (*OffObject) (struct Object *);
  50.     VOID  (*OnObject) (struct Object *);
  51.     VOID  (*Activate) (struct Object *);
  52. };
  53.  
  54.  
  55. // Classes d'objets
  56. #define CLASS_CYCLE            1
  57. #define CLASS_SCROLLER    2
  58. #define CLASS_BUTTON        3
  59. #define CLASS_INTEGER        4
  60. #define CLASS_STRING        5
  61. #define CLASS_CHECK            6
  62.  
  63. /* IDCMP flags for the window */
  64. #define IDCMP_CYCLE     (GADGETUP)
  65. #define IDCMP_SCROLLER  (GADGETDOWN|GADGETUP|MOUSEMOVE)
  66. #define IDCMP_BUTTON    (GADGETDOWN|GADGETUP)
  67. #define IDCMP_INTEGER   (GADGETDOWN|GADGETUP)
  68. #define IDCMP_STRING    (GADGETDOWN|GADGETUP)
  69. #define IDCMP_CHECK     (GADGETDOWN)
  70.  
  71.  
  72. struct NewObject
  73. {
  74.     UWORD  LeftEdge, TopEdge;            // position de l'objet
  75.     UWORD  Width, Height;                    // taille de l'objet
  76.     UWORD  Flags;                                    // Flags pour toutes les classes d'objet
  77.     UWORD  ClassFlags;                        // Flags specialise pour chaque classe
  78.     STRPTR LabelText;                            // Label de l'objet
  79.     struct TextAttr *Font;                // Fonte pour le label et le texte de l'objet
  80. };
  81.  
  82.  
  83. // Flags pour NewObject.Flags
  84. #define LABEL_MASK        0x007f        // position du label par rapport à l'objet
  85. #define LABEL_ABOVE     0x0001        // au dessus
  86. #define LABEL_BELOW     0x0002        // en dessous
  87. #define LABEL_RIGHT     0x0004        // a droite
  88. #define LABEL_LEFT        0x0008        // a gauche
  89. #define LABEL_INSIDE    0x0010        // a l'interieur
  90. #define LABEL_HOT_KEY    0x0020        // Souligne le caractères suivant le '_'
  91. #define LABEL_PEN2        0x0040        // Label ecrit avec la couleur Pen2
  92.  
  93. #define OBJ_DISABLED    0x0080        /* Object ghosted (Off) */
  94.  
  95.  
  96. struct NewCycle
  97. {
  98.     struct NewObject NewObj;
  99.     STRPTR *TextArray;
  100. };
  101.  
  102.  
  103. struct NewButton
  104. {
  105.     struct NewObject NewObj;
  106. };
  107.  
  108. // ClassFlags pour les boutons
  109. #define BT_TOGGLE            0x0001
  110. #define BT_SELECTED        0x0002
  111. #define BT_IMAGELABEL    0x0004
  112.  
  113. struct NewScroller
  114. {
  115.     struct NewObject NewObj;
  116.     UWORD Pos;
  117.     UWORD CurSize;
  118.     UWORD MaxSize;
  119. };
  120.  
  121. // ClassFlags pour les scrollers
  122. #define SC_VERTICAL        0x0001        // Scroller vertical
  123. #define SC_NOMOUSE        0x0002        // pas de FOLLOWMOUSE
  124.  
  125.  
  126. struct NewCheck
  127. {
  128.     struct NewObject NewObj;
  129. };
  130.  
  131. // ClassFlags pour les checks
  132. #define CK_CHECKED        0x0001        // le check est coche
  133.  
  134.  
  135. struct NewString
  136. {
  137.     struct NewObject NewObj;
  138.     STRPTR Text;
  139.     UWORD  MaxLength;
  140. };
  141.  
  142.  
  143. struct NewInteger
  144. {
  145.     struct NewObject NewObj;
  146. };
  147.  
  148. // ClassFlags pour les integer et les string
  149. #define STR_SINGLEBORD    0x0001
  150. #define STR_RIGHT                0x0002
  151. #define STR_CENTER            0x0004
  152.  
  153.  
  154. struct NewTextArea
  155. {
  156.     UWORD  LeftEdge, TopEdge;
  157.     UWORD  Width, Height;
  158.     UWORD  Flags;
  159.     UWORD  ClassFlags;
  160.     STRPTR LabelText;
  161.     struct TextAttr *Font;
  162.     UBYTE  FrontPen, BackPen;
  163.     UBYTE  InterLine;
  164.     UBYTE  WrMask;
  165. };
  166.  
  167. // flags pour NewTextArea.Flags
  168. #define LABEL_ABOVE     0x0001        // au dessus
  169. #define LABEL_BELOW     0x0002        // en dessous
  170. #define LABEL_RIGHT     0x0004        // a droite
  171. #define LABEL_LEFT        0x0008        // a gauche
  172. #define LABEL_PEN2        0x0040        // Label ecrit avec la couleur Pen2
  173.  
  174. // flags pour NewTextArea.ClassFlags
  175. #define TAF_SMOOTH_SCROLL 1
  176. #define TAF_CLIP_TEXT         2
  177.  
  178. struct Object
  179. {
  180.     struct ObjectTMV *TMV;
  181.     UWORD  ObjectID;
  182.     UWORD  Flags;
  183.     STRPTR LabelText;
  184.     struct TextFont *Font;
  185.     struct Window *window;
  186.     struct Requester *requester;
  187.     UWORD  ClassFlags;
  188.     struct Box BorderBox;
  189. };
  190.  
  191.  
  192. struct ObjectGad
  193. {
  194.     struct ObjectTMV *TMV;
  195.     UWORD  ObjectID;
  196.     UWORD  Flags;
  197.     STRPTR LabelText;
  198.     struct TextFont *Font;
  199.     struct Window *window;
  200.     struct Requester *requester;
  201.     UWORD  ClassFlags;
  202.     struct Box BorderBox;
  203.     struct Gadget Gadget;
  204. };
  205.  
  206.  
  207. struct DrawEnv
  208. {
  209.     UBYTE APen;
  210.     UBYTE BPen;
  211.     UBYTE DrMd;
  212. };
  213.  
  214.  
  215. struct TextEnv
  216. {
  217.     struct TextFont *Font;
  218.     struct DrawEnv *Env;
  219. };
  220.  
  221.  
  222. // methodes generiques pour les Object
  223. UWORD GetObjectID(struct Object *);
  224. struct Object *FindObjectMsg(struct IntuiMessage *);
  225. UBYTE GetHotKey(CPTR);
  226.  
  227. // private
  228. VOID InitObject(struct Object *, struct NewObject *);
  229. VOID InitObjectGad(struct ObjectGad *, struct NewObject *);
  230. VOID EraseObjectLabel(struct Object *, struct Box *);
  231. VOID PrintObjectLabel(struct Object *, struct Box *);
  232. VOID EraseObjectFrame(struct Object *, struct Box *);
  233. VOID OffObjectGad(struct ObjectGad *);
  234. VOID DisposeObject(struct Object *);
  235. VOID AddObject(struct ObjectGad *, struct Window *, struct Requester *);
  236. VOID RemoveObject(struct ObjectGad *);
  237.  
  238. // prototypes
  239. VOID SetIObjectColors(UBYTE, UBYTE, UBYTE, UBYTE, UBYTE);
  240. VOID Draw3DBox(struct Box *, struct RastPort *, UWORD);
  241. VOID AdjustBox(struct Box *, BOOL);
  242. VOID ExitEasyGadget();
  243. BOOL InitEasyGadget();
  244.  
  245. // private
  246. struct TextFont *LoadFont(struct TextAttr *);
  247. VOID PrintLabelText(struct RastPort *, struct Box *, STRPTR, UWORD);
  248. VOID EraseLabelText(struct RastPort *, struct Box *, STRPTR, UWORD);
  249. VOID FastDraw3DBox(struct Box *, struct RastPort *, UWORD);
  250. VOID EraseBox (struct Box *, struct RastPort *);
  251. VOID FastEraseBox (struct Box *, struct RastPort *);
  252. VOID SaveDrawEnv(struct RastPort *, struct DrawEnv *);
  253. VOID RestoreDrawEnv(struct RastPort *, struct DrawEnv *);
  254. VOID SaveTextEnv(struct RastPort *, struct TextEnv *);
  255. VOID RestoreTextEnv(struct RastPort *, struct TextEnv *);
  256. VOID SetActiveObject(struct Object *, ULONG);
  257. VOID GhostInnerBox(struct Box *, struct RastPort *, BOOL);
  258. VOID GhostBox(struct Box *, struct RastPort *);
  259. VOID DoNothing();
  260.  
  261.  
  262. // methodes pour les objets
  263. struct Cycle *CreateCycle(struct NewCycle *, ULONG);
  264. struct Button *CreateButton(struct NewButton *, ULONG);
  265. struct Check *CreateCheck(struct NewCheck *, ULONG);
  266. struct Scroller *CreateScroller(struct NewScroller *, ULONG);
  267. struct Integer *CreateInteger(struct NewInteger *, ULONG);
  268. struct String *CreateString(struct NewString *, ULONG);
  269.  
  270. VOID FreeObject(struct Object *);
  271. BOOL SendMsgToObject(struct Object *, struct IntuiMessage *);
  272. VOID AddObjectToWindow(struct Object *, struct Window *, struct Requester *);
  273. VOID RemoveObjectFromWindow(struct Object *);
  274. VOID DisplayObject(struct Object *);
  275. VOID EraseObject(struct Object *);
  276. VOID ModifyObject(struct Object *, ...);
  277. ULONG ObjectValue(struct Object *);
  278. struct Object *CreateObject(struct NewObject *, UWORD, UWORD);
  279. VOID ActivateObject(struct Object *);
  280. VOID OnObject(struct Object *);
  281. VOID OffObject(struct Object *);
  282.  
  283. // Prototypes pour les TextArea
  284. struct TextArea *CreateTextArea(struct NewTextArea *, struct RastPort *);
  285. VOID FreeTextArea(struct TextArea *);
  286. VOID TAPuts(struct TextArea *,char *);
  287. VOID TAPrint(struct TextArea *,char *);
  288. VOID TAPrintf(struct TextArea *,char *, ...);
  289.  
  290. // Prototypes des libraries
  291. extern int sprintf(char *, const char *, ...);
  292. extern long strlen(char *);
  293. extern char *strchr(const char *, int);
  294. extern void *memcpy(void *, const void *, long);
  295. extern char *AllocMem(long, long);
  296. extern void FreeMem(void *, long);
  297. extern long SetSoftStyle(struct RastPort *, long, long);
  298. extern void RectFill(struct RastPort *, long, long, long, long);
  299. extern long TextLength(struct RastPort *, char *, long);
  300. extern long Text(struct RastPort *, char *, long);
  301. extern long SetFont(struct RastPort *, struct TextFont*);
  302. extern struct TextFont *OpenFont(struct TextAttr *);
  303. extern void CloseFont(struct TextFont *);
  304. extern void Move(struct RastPort *, long, long);
  305. extern void Draw(struct RastPort *, long, long);
  306. extern void SetAPen(struct RastPort *, long);
  307. extern void SetBPen(struct RastPort *, long);
  308. extern void SetDrMd(struct RastPort *, long);
  309. extern struct TextFont *OpenDiskFont(struct textAttr *);
  310. extern void DrawImage(struct RastPort *, struct Image *, long, long);
  311. extern void RefreshGList(struct Gadget *, struct Window *, struct Requester *, long);
  312. extern long AddGList(struct Window *, struct Gadget *, long, long, struct Requester *);
  313. extern long RemoveGList(struct Window *, struct Gadget *, long);
  314. extern void RefreshGadgets(struct Gadget *, struct Window *, struct Requester *);
  315. extern long RemoveGadget(struct Window *, struct Gadget *);
  316. extern void RefreshGadgets(struct Gadget *, struct Window *, struct Requester *);
  317. extern long RemoveGadget(struct Window *, struct Gadget *);
  318. extern long AddGadget(struct Window *, struct Gadget *, long);
  319. extern void NewModifyProp(struct Gadget *, struct Window *, struct Requester *, long, long, long, long, long, long);
  320. long ActivateGadget(struct Gadget *, struct Window *, struct Requester *);
  321. void DisplayBeep(struct Screen *);
  322. void OffGadget(struct Gadget *, struct Window *, struct Requester *);
  323. void OnGadget(struct Gadget *, struct Window *, struct Requester *);
  324.